#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1

export HOME=/tmp

%:
	dh $@ --with bash-completion

override_dh_auto_build:
ifeq (,$(filter nodoc,$(DEB_BUILD_PROFILES)))
	make doc
endif

override_dh_auto_clean:
	-make clean
	rm -f test/fixtures/config/userconfig-with-gc

override_dh_clean:
	dh_clean

override_dh_fixperms:
	dh_fixperms
	chmod a-x debian/npm/usr/share/npm/lib/utils/completion.sh
	chmod a-x debian/npm/usr/share/npm/node_modules/uid-number/get-uid-gid.js
	chmod a-x debian/npm/usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin/node-gyp.cmd
	chmod a+x debian/npm/usr/share/npm/bin/npm-cli.js
	chmod a+x debian/npm/usr/share/npm/bin/npx-cli.js

override_dh_auto_install:
	# NO OP

override_dh_install:
	dh_install
	find debian/npm -iname LICENSE -delete
	find debian/npm -iname LICENCE -delete
	find debian/npm -iname LICENSE.txt -delete
	find debian/npm -iname LICENSE.md -delete
	find debian/npm/usr/share/npm/node_modules -name .npmignore -delete
	find debian/npm/usr/share/npm/node_modules -name .eslintrc.json -delete
	find debian/npm/usr/share/npm/node_modules -name .eslintrc -delete

override_dh_auto_test:
	cp debian/npmrc npmrc
	# the tests need npm-registry-mock module to run
	# and some of them fail by design
	#tap --timeout 240 "test/tap/*.js"
